package name.sakanacatcher.service;

import name.sakanacatcher.entity.Role;
import name.sakanacatcher.entity.User;
import name.sakanacatcher.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class AuthService {

    @Autowired
    ResultUtil resultUtil;

    @Autowired
    RoleService roleService;

    @Autowired
    UserService userService;

    @Autowired
    ComService comService;

    public boolean isAdmin(User user){
        for (Role role:user.getRoles()){
            if (role.getRole().equals("admin")){
                return true;
            }
        }
        return false;
    }

    public boolean isCEO(User user){
        for (Role role:user.getRoles()){
            if (role.getRole().equals("公司负责人")){
                return true;
            }
        }
        return false;
    }
    public boolean isHR(User user){
        for (Role role:user.getRoles()){
            if (role.getRole().equals("HR")){
                return true;
            }
        }
        return false;
    }

}
